<fieldset>
    <legend>条件搜索</legend>
    <form action="{:request()->url()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">产品名称</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="goods_name" placeholder="请输入产品名称" value="{:input('goods_name')}">
            </label>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">客户名称</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="name" placeholder="请输入客户名称" value="{:input('name')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">身份证号</label>
            <label class="layui-input-inline">
                <input class="layui-input" name="idcard" placeholder="请输入身份证号" value="{:input('idcard')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">投资状态</label>
            <label class="layui-input-inline">
                <select class="layui-select" name="expire_status">
                    <option value=''>- 全部 -</option>
                    {foreach [1=>'已过期',0=>'未过期'] as $k=>$v}
                    {if input('expire_status') eq $k.''}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">付款方式</label>
            <label class="layui-input-inline">
                <select class="layui-select" name="payment_method">
                    <option value=''>-- 全部 --</option>
                    {foreach ['0'=>'划卡','1'=>'转账','2'=>'现金','3'=>'续投'] as $k=>$v}
                    {if input('payment_status') eq $k.''}
                    <option selected value="{$k}">{$v}</option>
                    {else}
                    <option value="{$k}">{$v}</option>
                    {/if}{/foreach}
                </select>
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">业务员</label>
            <label class="layui-input-inline">
                <select class="layui-select" name="staff_id">
                    <option value=''>-- 全部 --</option>
                    {foreach $staff_list as $k=>$v}
                    {if input('staff_id') eq $v.id .''}
                    <option selected value="{$v.id}">{$v.name}</option>
                    {else}
                    <option value="{$v.id}">{$v.name}</option>
                    {/if}{/foreach}
                </select>
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">开始时间</label>
            <label class="layui-input-inline">
                <input class="layui-input" data-date-range name="start_at" placeholder="请选择开始时间" value="{:input('start_at')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">到期时间</label>
            <label class="layui-input-inline">
                <input class="layui-input" data-date-range name="end_at" placeholder="请选择过期时间" value="{:input('end_at')}">
            </label>
        </div>

        <div class="layui-form-item layui-inline pull-right">
            <button class="layui-btn layui-btn-primary" type="submit"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            <button class="layui-btn layui-btn-primary" data-form-export="{:url('index')}?type={$type|default=''}" type="button">
                <i class="layui-icon layui-icon-export"></i> 导 出
            </button>
        </div>
    </form>
</fieldset>

<script>
    window.form.render();
    require(['excel'], function (excel) {
        excel.bind(function (data) {
            var items = [];
            items.push(['业务员', '客户姓名','客户手机号','客户身份证号','开户行','收款卡号','客户编号','合同编号','投资金额(规模)',
                '收款方式', '产品名称', '起息日期', '到期日期', '投资日期', '年利率', '预计到期利息', '预计到期利息复利',
                '预计满整月利息金额', '预计当月应付利息金额','预计到期当月利息金额', '当前已付利息总额','当前利息复利总额', '应扣利息差额', '折标']);
            data.forEach(function (order) {
                items.push([
                    order.staff_name,
                    order.name,
                    order.phone,
                    order.idcard,
                    order.account_bank,
                    order.bank_no,
                    order.customer_no,
                    order.contract_no,
                    order.money,
                    order.payment_method == 1 ? '转账' : '划卡',
                    order.goods_name,
                    order.start_at || '',
                    order.end_at,
                    order.invest_date,
                    order.goods_annual_rate,
                    order.expect_lxje,
                    order.expect_lxflje,
                    order.full_month_lxje,
                    order.current_month_lxje,
                    order.expire_month_lxje,
                    order.current_lxje,
                    order.current_lxflje,
                    order.lxce,
                    order.zhebiao,
                ]);
            });
            return items;
        }, '用户订单记录');
    });
</script>